<!--********************************************************************
* Copyright© 2000 - 2025 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title data-i18n="resources.text_editor"></title>
    <style type="text/css">
        body {
            margin: 0;
            overflow: hidden;
            background: #fff;
            width: 100%;
            height: 100%
        }

        #map {
            position: absolute;
            width: 100%;
            height: 100%;
        }

        #toolbar {
            position: absolute;
            top: 50px;
            right: 10px;
            text-align: center;
            z-index: 100;
            border-radius: 4px;
        }
    </style>
</head>
<body>
<div id="toolbar" class="panel panel-primary">
    <div class='panel-heading'>
        <h5 class='panel-title text-center' data-i18n="resources.text_editor"></h5></div>
    <div class='panel-body content'>
        <input id="btn_Copy" type="button" class="btn btn-default" data-i18n="[value]resources.btn_copy" onclick="copySymbol()"/>
        <input id="btn_Cut" type="button" class="btn btn-default" data-i18n="[value]resources.btn_cut" onclick="cutSymbol()"/>
        <input id="btn_Paste" type="button" class="btn btn-default" data-i18n="[value]resources.btn_paste" onclick="pasteSymbol()"/>
        <input id="btn_Reset" type="button" class="btn btn-default" data-i18n="[value]resources.btn_reset" onclick="resetSymbol()"/>
    </div>
</div>
<div id="map"></div>
<script type="text/javascript" include="bootstrap" src="../js/include-web.js"></script>
<script type="text/javascript" exclude="iclient-classic" include="iclient8c-plot" src="../../dist/classic/include-classic.js"></script>
<script>
    var plottingLayer, plottingEdit, layer;
    var drawGraphicObject, map, plotting, editor;
    var host = window.isLocal ? window.server : "https://iserver.supermap.io";
    var mapurl = host + "/iserver/services/map-world/rest/maps/World";
    var serverUrl = host + "/iserver/services/plot-jingyong/rest/plot/";
    init();

    function init() {
        map = new SuperMap.Map("map", {
            controls: [
                new SuperMap.Control.ScaleLine(),
                new SuperMap.Control.Zoom(),
                new SuperMap.Control.Navigation({
                    dragPanOptions: {
                        enableKinetic: true
                    }
                })]
        });
        map.addControl(new SuperMap.Control.LayerSwitcher(), new SuperMap.Pixel(42, 80));
        layer = new SuperMap.Layer.TiledDynamicRESTLayer("World", mapurl, {
            transparent: true,
            cacheEnabled: true
        }, {maxResolution: "auto"});
        layer.events.on({"layerInitialized": addLayer});

        plottingLayer = new SuperMap.Layer.PlottingLayer("标绘图层", serverUrl);
        plottingLayer.style = {
            fillColor: "#66cccc",
            fillOpacity: 0.4,
            strokeColor: "#66cccc",
            strokeOpacity: 1,
            strokeWidth: 3,
            pointRadius: 6
        };

        //态势标绘编辑
        plottingEdit = new SuperMap.Control.PlottingEdit();

        //添加态势标绘控件
        map.addControls([plottingEdit]);

        plotting = SuperMap.Plotting.getInstance(map, serverUrl);
        editor = plotting.getEditor();
    }

    function addLayer() {
        map.addLayers([layer, plottingLayer]);
        map.setCenter(new SuperMap.LonLat(0, 0), 0);

        //标绘标号
        plotSymbol();

        plottingEdit.activate();
    }

    function plotSymbol() {

        //标绘多边形
        var polygonPoints = [];
        polygonPoints.push(new SuperMap.Geometry.Point(-20, 0));
        polygonPoints.push(new SuperMap.Geometry.Point(-10, 20));
        polygonPoints.push(new SuperMap.Geometry.Point(-30, 40));
        polygonPoints.push(new SuperMap.Geometry.Point(-60, 10));
        plottingLayer.createSymbolWC(0, SuperMap.Plot.SymbolType.ARBITRARYPOLYGONSYMBOL, polygonPoints);

        //标绘折线
        var linePoints = [];
        linePoints.push(new SuperMap.Geometry.Point(0, 0));
        linePoints.push(new SuperMap.Geometry.Point(0, 20));
        linePoints.push(new SuperMap.Geometry.Point(20, 10));
        linePoints.push(new SuperMap.Geometry.Point(10, 30));
        plottingLayer.createSymbolWC(0, SuperMap.Plot.SymbolType.POLYLINESYMBOL, linePoints);
    }

    function copySymbol() {
        editor.copy();
    }

    function cutSymbol() {
        editor.cut();
    }

    function pasteSymbol() {
        editor.paste();
    }

    function resetSymbol() {
        plottingLayer.removeAllFeatures();
        plotSymbol();
    }
</script>

</body>
</html>